using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing.Design;
using System.Text;
using System.Windows.Forms;
using PrintTray.Properties;
using System.Drawing.Printing;

namespace PrintTray
{

    public class PrinterSettingsEditor : UITypeEditor
    {
        private PrintDialog printDialog;

        public PrinterSettingsEditor()
        {
            printDialog = new System.Windows.Forms.PrintDialog();
            printDialog.UseEXDialog = true;
        }

        public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext context)
        {

            return UITypeEditorEditStyle.Modal;

        }



        public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
        {



            //printDialog.PrinterSettings = Settings.Default.UserSettings.PrintSettings;

            printDialog.PrinterSettings = value as PrinterSettings;

            printDialog.ShowDialog();

            value = Settings.Default.UserSettings.PrintSettings = printDialog.PrinterSettings;

            return value;

        }

    }
}
